<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <script th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <style>
        form{
            width: 30%;
        }
        #container{
            width:100%;
            display: flex;
            justify-content: center;
            padding-top: 30px;
        }
    </style>
</head>
<body>
    <div id="container" onsubmit="return false">
        <form id="formData">
            <div class="form-group">
                <label for="username">用户名：</label>
                <input type="text" class="form-control" id="username" name="username" placeholder="用户名" required>
            </div>
            <div class="form-group">
                <label for="password">密码：</label>
                <input type="password" name="password" class="form-control" id="password" placeholder="密码" required>
            </div>
            <!--<div class="form-group">-->
                <!--<label>管理员：-->
                    <!--<input type="radio" name="role" value="admin">-->
                <!--</label>-->
                <!--<label>-->
                    <!--用户：-->
                    <!--<input type="radio" name="role" value="customer">-->
                <!--</label>-->
            <!--</div>-->

            <button type="submit" id="login"  class="btn btn-default">登录</button>
        </form>
    </div>
    <script>
        $(function(){
            $("#login").click(function(){

                $.ajax({
                    url:"/user/login",
                    data:$("#formData").serialize(),
                    type:"post",
                    success:function(data){
                        console.log(data)
                        if(data=='success'){
                            location.href="/router/main";
                            return;
                        }
                        alert("登录失败")

                    },

                })
            })

        })
    </script>
</body>
</html>